package de.koller.worlders.engine.tiles.landscape.generator;

import de.koller.worlders.WorldersRoot;
import java.awt.image.BufferedImage;

public class Generator {
	
	private Generator() {}
	
	public static void gen( int tx, int ty, IGenType gen, WorldersRoot wroot ) {
		BufferedImage m = gen.generateMap();
		BufferedImage l = gen.generateLight();
		
		if( m != null )
			for( int x = 0; x < m.getWidth(); x++ )
				for( int y = 0; y < m.getHeight(); y++ ) {
					int c = m.getRGB( x, y );
					if( c != 0x00000000 )
						wroot.getTileMap().tileHolder.setMapData( tx+x, ty+y, c );
				}
		
		if( l != null )
			for( int x = 0; x < m.getWidth(); x++ )
				for( int y = 0; y < m.getHeight(); y++ ) {
					int c = l.getRGB( x, y );
					if( c != 0x00000000 )
						wroot.getTileMap().tileHolder.setLightData( tx+x, ty+y, c );
				}
				
		wroot.syncClear.reloadAll();
	}
	
}
